<?php
namespace App\Http\Controllers\Backend\Sysconf;

use App\Http\Controllers\Backend\BaseController;
use App\Http\Requests\Backend\Sysconf\BasicRequest;
use App\Repositories\PrtSysConfRepository;
use Illuminate\Http\Request;

/**
 * 项目的整体基础配置
 * @author:yanxs<541139655@qq.com>
 * @version: 1.0
 * @date:2021/7/13
 */
class BasicController extends BaseController
{
    protected $viewPath = 'backend.sysconf.basic';  //当前控制器所的view所在的目录
    protected $modules = 'sys';        //当前控制器所属模块
    protected $codePrefix = '';        //编码前缀
    public function __construct(PrtSysConfRepository $Repository)
    {
        //var_dump(\Illuminate\Support\Facades\Request::session());exit;
        parent::__construct();
        $this->repositories = $Repository;
        view()->share("style_list",config("common.sys_style"));
    }

    //添加/编辑操作
    public function save(BasicRequest $request)
    {
        $params = $request->all();
        //$params['sys_code'] = $this->codePrefix;
        $userInfo = $this->getUserInfo();
        if (!$params['id']) {
            $params['creator_uid'] = $userInfo['id'];
        } else {
            $params['updater_uid'] = $userInfo['id'];
        }
        $ret = $this->repositories->save($params);
        if ($ret) {
            return $this->jsonSuccess([]);
        } else {
            return $this->jsonFailed('');
        }
    }

}
